import sys

class UDExp:
    """user defined exception class"""
    def __init__(self):
        self.error=""
    def ArgNumExp(self,args,argsNum):
        """check the number of arguments from the command line is enough for some operation."""
        if len(args) != argsNum+1:
            errors = ("""
            Argument number error!! 
            Usage: there should be """ + str(argsNum) +( " argument " if argsNum < 2 else " arguments ") + "but now "+ \
                     str(len(args)-1) +".").strip()
            if len(args)>1:
                print("args now is " + str(args[1:]))
            raise Exception(errors)